package com.kmproject.haifu.mvp.presenter;

import android.Manifest;
import android.app.Activity;
import android.app.Application;
import android.content.Intent;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.text.TextUtils;
import android.view.View;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.alibaba.sdk.android.oss.ServiceException;
import com.alibaba.sdk.android.oss.model.PutObjectResult;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.jess.arms.di.scope.ActivityScope;
import com.jess.arms.http.imageloader.ImageLoader;
import com.jess.arms.integration.AppManager;
import com.jess.arms.mvp.BasePresenter;
import com.jess.arms.utils.ArmsUtils;
import com.jess.arms.utils.PermissionUtil;
import com.jess.arms.widget.CustomPopupWindow;
import com.jess.arms.widget.autolayout.AutoToolbar;
import com.kmproject.haifu.R;
import com.kmproject.haifu.app.AppConstant;
import com.kmproject.haifu.app.hfinterface.AliYunUploadFileInterface;
import com.kmproject.haifu.app.hfinterface.SecondHandItemClickCall;
import com.kmproject.haifu.app.utils.AppUtil;
import com.kmproject.haifu.app.utils.RxUtils;
import com.kmproject.haifu.app.utils.StringUtils;
import com.kmproject.haifu.mvp.contract.SecondHandPublicshContract;
import com.kmproject.haifu.mvp.model.api.Api;
import com.kmproject.haifu.mvp.model.entity.ResultBean;
import com.kmproject.haifu.mvp.model.entity.beans.HousePayWayBean;
import com.kmproject.haifu.mvp.model.entity.beans.MemberCenterUserInfoBean;
import com.kmproject.haifu.mvp.model.entity.beans.MyStoryBean;
import com.kmproject.haifu.mvp.model.entity.beans.SecondHandInfoBean;
import com.kmproject.haifu.mvp.model.entity.beans.SecondHandTreeTypeBean;
import com.kmproject.haifu.mvp.model.entity.resbean.SecondHandSaveRequest;
import com.kmproject.haifu.mvp.ui.activity.MyCollectionActivity;
import com.kmproject.haifu.mvp.ui.adapter.PublicHouseXZDPItemAdapter;
import com.kmproject.haifu.mvp.ui.adapter.SecondhandPublicshSelectTypeAdapter;
import com.kmproject.haifu.mvp.ui.adapter.SecondhandPublicshSelectTypeItemAdapter;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.inject.Inject;

import butterknife.BindView;
import butterknife.ButterKnife;
import me.jessyan.rxerrorhandler.core.RxErrorHandler;
import me.jessyan.rxerrorhandler.handler.ErrorHandleSubscriber;


/**
 * ================================================
 * Description:
 * <p>
 * Created by MVPArmsTemplate on 08/27/2019 13:44
 * <a href="mailto:jess.yan.effort@gmail.com">Contact me</a>
 * <a href="https://github.com/JessYanCoding">Follow me</a>
 * <a href="https://github.com/JessYanCoding/MVPArms">Star me</a>
 * <a href="https://github.com/JessYanCoding/MVPArms/wiki">See me</a>
 * <a href="https://github.com/JessYanCoding/MVPArmsTemplate">模版请保持更新</a>
 * ================================================
 */
@ActivityScope
public class SecondHandPublicshPresenter extends BasePresenter<SecondHandPublicshContract.Model, SecondHandPublicshContract.View> {
    @Inject
    RxErrorHandler mErrorHandler;
    @Inject
    Application mApplication;
    @Inject
    ImageLoader mImageLoader;
    @Inject
    AppManager mAppManager;
    private CustomPopupWindow customPopupWindowSelectStore;//选择归属店铺的view
    private PopuwindowSelectStoreViewHold popuwindowSelectStoreViewHold;
    String[] permission = {Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE, Manifest.permission.CAMERA};
    private CustomPopupWindow customPopupWindowSelectType;//选择类型
    PopuwindowSelectTypeViewHold popuwindowSelectTypeViewHold;

    private CustomPopupWindow customPopupWindowSetPrice;//选择类型
    PopuwindowSetPriceViewHold popuwindowSetPriceViewHold;

    @Inject
    public SecondHandPublicshPresenter(SecondHandPublicshContract.Model model, SecondHandPublicshContract.View rootView) {
        super(model, rootView);
    }

    /**
     * 发布成功
     *
     * @param activity
     * @param view
     * @param
     */
    public void popuwindPublishSuccess(Activity activity, View view, String msg) {

        CustomPopupWindow publishSuccess = new CustomPopupWindow.Builder().contentView(CustomPopupWindow.inflateView(activity, R.layout.secondhandpublish_add_success)).parentView(view)
                .animationStyle(R.style.mypopwindow_anim_style).customListener(new CustomPopupWindow.CustomPopupWindowListener() {
                    @Override
                    public void initPopupView(View contentView) {

                    }
                }).isHaveBackGround(false).build();
        View view1 = publishSuccess.getContentView();
        PopuwindowPublishSuccessViewHold     popuwindowPublishSuccessViewHold = new PopuwindowPublishSuccessViewHold(view1);
        popuwindowPublishSuccessViewHold.toolbarTitle.setText(ArmsUtils.getString(activity, R.string.second_hand_publicsh_success));
        popuwindowPublishSuccessViewHold.toolbarTitle.setTextColor(ArmsUtils.getColor(activity, R.color.color_191919));
        popuwindowPublishSuccessViewHold.toolbar.setBackgroundColor(ArmsUtils.getColor(activity, R.color.color_EDEDED));
        popuwindowPublishSuccessViewHold.toolbarBack.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                publishSuccess.dismiss();
                mRootView.killMyself();
            }
        });
        if (msg.length()>10)
        {
            popuwindowPublishSuccessViewHold.secondhandpublishMsg.setText(msg);
        }
        popuwindowPublishSuccessViewHold.secondhandpublishCkwdfb.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent=new Intent(activity, MyCollectionActivity.class);
                intent.putExtra("type",0);
                intent.putExtra("defaultSelecIndex",2);
                ArmsUtils.startActivity(intent);
                publishSuccess.dismiss();
                mRootView.killMyself();
            }
        });
        popuwindowPublishSuccessViewHold.secondhandpublishJxfb.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                publishSuccess.dismiss();
                mRootView.killMyself();
            }
        });
        publishSuccess.show();
    }

    /**
     * 得到选中的标签id
     *
     * @param housePayWayBeansBq
     * @return
     */
    public List<String> getLabs(List<HousePayWayBean> housePayWayBeansBq) {
        List<String> labsIds = new ArrayList<>();
        if (housePayWayBeansBq == null || housePayWayBeansBq.isEmpty()) {
            return labsIds;
        }
        for (HousePayWayBean housePayWayBean : housePayWayBeansBq) {
            if (housePayWayBean.isSelect()) {
                labsIds.add(housePayWayBean.getDictId());
            }
        }
        return labsIds;
    }

    /**
     * 发布
     *
     * @param secondHandSaveRequest
     */
    public void secondHandAdd(SecondHandSaveRequest secondHandSaveRequest) {
        mModel.secondHandAdd(AppUtil.entityToMap(secondHandSaveRequest)).compose(RxUtils.applySchedulers(mRootView))
                .subscribe(new ErrorHandleSubscriber<ResultBean<SecondHandInfoBean>>(mErrorHandler) {
                    @Override
                    public void onNext(ResultBean<SecondHandInfoBean> secondHandInfoBeanResultBean) {
                        if (AppUtil.isSuccess(secondHandInfoBeanResultBean)) {
                            mRootView.secondHandAddSuccess(secondHandInfoBeanResultBean);
                        } else {
                            mRootView.showMessage(secondHandInfoBeanResultBean.getMessage());
                        }
                    }
                });
    }


    /**
     * 编辑
     *
     * @param secondhandId
     * @param secondHandSaveRequest
     */
    public void secondHandEdit(String secondhandId, SecondHandSaveRequest secondHandSaveRequest) {
        mModel.secondHandEdit(Api.SECONDHAND_PUBLISH_PUBLISH_EDIT_ONE + secondhandId, AppUtil.entityToMap(secondHandSaveRequest))
                .compose(RxUtils.applySchedulers(mRootView))
                .subscribe(new ErrorHandleSubscriber<ResultBean<SecondHandInfoBean>>(mErrorHandler) {
                    @Override
                    public void onNext(ResultBean<SecondHandInfoBean> secondHandInfoBeanResultBean) {
                        if (AppUtil.isSuccess(secondHandInfoBeanResultBean)) {
                            mRootView.secondHandEditSuccess(secondHandInfoBeanResultBean);
                        } else {
                            mRootView.showMessage(secondHandInfoBeanResultBean.getMessage());
                        }
                    }
                });
    }


    /**
     * 查询
     *
     * @param secondhandId
     */
    public void secondHandLookOne(String secondhandId) {
        mModel.secondHandLookOne(Api.SECONDHAND_PUBLISH_PUBLISH_LOOK_ONE + secondhandId)
                .compose(RxUtils.applySchedulers(mRootView))
                .subscribe(new ErrorHandleSubscriber<ResultBean<SecondHandInfoBean>>(mErrorHandler) {
                    @Override
                    public void onNext(ResultBean<SecondHandInfoBean> secondHandInfoBeanResultBean) {
                        if (AppUtil.isSuccess(secondHandInfoBeanResultBean)) {
                            mRootView.secondHandLookOneSuccess(secondHandInfoBeanResultBean.getData());
                        } else {
                            mRootView.showMessage(secondHandInfoBeanResultBean.getMessage());
                        }
                    }
                });
    }

    /**
     * 设置价格
     *
     * @param activity
     * @param view
     * @param priceSetCall
     */
    public void popuwindSelectSetPrice(Activity activity, View view, priceSetCall priceSetCall,SecondHandSaveRequest secondHandSaveRequest) {
       if (customPopupWindowSetPrice!=null)
       {
           customPopupWindowSetPrice.show();
           return;
       }
        customPopupWindowSetPrice = new CustomPopupWindow.Builder().contentView(CustomPopupWindow.inflateView(activity, R.layout.secondhand_publicsh_price_set)).parentView(view)
                .animationStyle(R.style.mypopwindow_anim_style).customListener(new CustomPopupWindow.CustomPopupWindowListener() {
                    @Override
                    public void initPopupView(View contentView) {

                    }
                }).isHaveBackGround(false).build();
        View view1 = customPopupWindowSetPrice.getContentView();
        popuwindowSetPriceViewHold = new PopuwindowSetPriceViewHold(view1);
        if (secondHandSaveRequest!=null&&secondHandSaveRequest.getSalePrice()!=null&&Double.parseDouble(secondHandSaveRequest.getSalePrice())>0)
        {
            popuwindowSetPriceViewHold.secondHandPublicshSetQwmjTxt.setText(secondHandSaveRequest.getSalePrice());
        }
        if (secondHandSaveRequest!=null&&secondHandSaveRequest.getBuyPrice()!=null&&Double.parseDouble(secondHandSaveRequest.getBuyPrice())>0)
        {
            popuwindowSetPriceViewHold.secondHandPublicshSetRsjTxt.setText(secondHandSaveRequest.getBuyPrice());
        }
        popuwindowSetPriceViewHold.toolbarBack.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                customPopupWindowSetPrice.dismiss();
            }
        });
        popuwindowSetPriceViewHold.UserSetEditInfoSetTxtSureTxt.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (StringUtils.ViewisEnpty(popuwindowSetPriceViewHold.secondHandPublicshSetQwmjTxt)) {
                    mRootView.showMessage("请输入期望价格");
                    return;
                }
                priceSetCall.callBack(popuwindowSetPriceViewHold.secondHandPublicshSetQwmjTxt.getText().toString(), popuwindowSetPriceViewHold.secondHandPublicshSetRsjTxt.getText().toString());
                customPopupWindowSetPrice.dismiss();
            }
        });
        customPopupWindowSetPrice.show();
    }

    /**
     * 选择发布类型
     *
     * @param activity
     * @param view
     * @param
     * @param
     * @param
     */
    public void popuwindSelectpublishType(Activity activity, View view, List<SecondHandTreeTypeBean> secondHandTreeTypeBeans, SecondHandItemClickCall itemClickCall) {
       if (customPopupWindowSelectType!=null)
       {
           customPopupWindowSelectType.show();
           return;
       }
        customPopupWindowSelectType = new CustomPopupWindow.Builder().contentView(CustomPopupWindow.inflateView(activity, R.layout.secondhand_publicsh_selecttype)).parentView(view)
                .animationStyle(R.style.mypopwindow_anim_style).customListener(new CustomPopupWindow.CustomPopupWindowListener() {
                    @Override
                    public void initPopupView(View contentView) {

                    }
                }).isHaveBackGround(false).build();
        View view1 = customPopupWindowSelectType.getContentView();
        popuwindowSelectTypeViewHold = new PopuwindowSelectTypeViewHold(view1);
        popuwindowSelectTypeViewHold.toolbarTitle.setText(ArmsUtils.getString(activity, R.string.housepublishpublish_title_xzgsdp));
        popuwindowSelectTypeViewHold.toolbarTitle.setTextColor(ArmsUtils.getColor(activity, R.color.color_191919));
        popuwindowSelectTypeViewHold.toolbar.setBackgroundColor(ArmsUtils.getColor(activity, R.color.color_EDEDED));
        popuwindowSelectTypeViewHold.toolbarBack.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                customPopupWindowSelectType.dismiss();
            }
        });
        //第二级
        popuwindowSelectTypeViewHold.secondhandPublicshSelecttypeRecyclerView2.setLayoutManager(new LinearLayoutManager(activity));
        SecondhandPublicshSelectTypeItemAdapter secondhandPublicshSelectTypeItemAdapter = new SecondhandPublicshSelectTypeItemAdapter(null, new SecondHandItemClickCall() {
            @Override
            public void call(SecondHandTreeTypeBean secondHandTreeTypeBean) {
                itemClickCall.call(secondHandTreeTypeBean);
                customPopupWindowSelectType.dismiss();
            }
        });
        popuwindowSelectTypeViewHold.secondhandPublicshSelecttypeRecyclerView2.setAdapter(secondhandPublicshSelectTypeItemAdapter);
        secondhandPublicshSelectTypeItemAdapter.openLoadAnimation(BaseQuickAdapter.SLIDEIN_RIGHT);

        //第一级
        popuwindowSelectTypeViewHold.secondhandPublicshSelecttypeRecyclerView1.setLayoutManager(new LinearLayoutManager(activity));
        SecondhandPublicshSelectTypeAdapter secondhandPublicshSelectTypeAdapter = new SecondhandPublicshSelectTypeAdapter(secondHandTreeTypeBeans, new SecondHandItemClickCall() {
            @Override
            public void call(SecondHandTreeTypeBean secondHandTreeTypeBean) {
                secondhandPublicshSelectTypeItemAdapter.setNewData(secondHandTreeTypeBean.getChildren());
            }
        });
        popuwindowSelectTypeViewHold.secondhandPublicshSelecttypeRecyclerView1.setAdapter(secondhandPublicshSelectTypeAdapter);
        secondhandPublicshSelectTypeAdapter.openLoadAnimation(BaseQuickAdapter.SLIDEIN_RIGHT);
        customPopupWindowSelectType.show();
    }

    /**
     * secondHandTreeTypeBeans
     * 获取分类
     */
    public void secondHandCategoryTree(List<SecondHandTreeTypeBean> secondHandTreeTypeBeans) {
        if (secondHandTreeTypeBeans != null && !secondHandTreeTypeBeans.isEmpty()) {
            mRootView.secondHandCategoryTreeSuccess(secondHandTreeTypeBeans);
            return;
        }
        mModel.secondHandCategoryTree().compose(RxUtils.applySchedulers(mRootView))
                .subscribe(new ErrorHandleSubscriber<ResultBean<List<SecondHandTreeTypeBean>>>(mErrorHandler) {
                    @Override
                    public void onNext(ResultBean<List<SecondHandTreeTypeBean>> listResultBean) {
                        if (AppUtil.isSuccess(listResultBean)) {
                            mRootView.secondHandCategoryTreeSuccess(listResultBean.getData());
                        } else {
                            mRootView.showMessage(listResultBean.getMessage());
                        }
                    }
                });
    }

    /**
     * 获取区域信息
     *
     * @param value
     * @param housePayWayBeans
     */
    public void getHouseArea(String value, List<HousePayWayBean> housePayWayBeans) {
        if (housePayWayBeans != null && !housePayWayBeans.isEmpty()) {
            mRootView.dictListSuccess(value, housePayWayBeans);
            return;
        }
        mModel.getAreaTree(Api.APP_DOMAIN_ZIDIAN + "/app/baseArea/getAreaTree", value, "").compose(RxUtils.applySchedulers(mRootView))
                .subscribe(new ErrorHandleSubscriber<ResultBean<List<HousePayWayBean>>>(mErrorHandler) {
                    @Override
                    public void onNext(ResultBean<List<HousePayWayBean>> listResultBean) {
                        if (AppUtil.isSuccess(listResultBean)) {
                            mRootView.dictListSuccess(value, listResultBean.getData());
                        } else {
                            mRootView.showMessage(listResultBean.getMessage());
                        }
                    }
                });
    }

    /**
     * 获取付款方式
     *
     * @param value
     * @param category
     */
    public void getHousePayWayBean(String value, String category, List<HousePayWayBean> housePayWayBeans) {
        if (housePayWayBeans != null && !housePayWayBeans.isEmpty()) {
            mRootView.dictListSuccess(value, housePayWayBeans);
            return;
        }//dictList4Category

        mModel.dictList(value, category).compose(RxUtils.applySchedulers(mRootView))
                .subscribe(new ErrorHandleSubscriber<ResultBean<List<HousePayWayBean>>>(mErrorHandler) {
                    @Override
                    public void onNext(ResultBean<List<HousePayWayBean>> listResultBean) {
                        if (AppUtil.isSuccess(listResultBean)) {
                            mRootView.dictListSuccess(value, listResultBean.getData());
                        } else {
                            mRootView.showMessage(listResultBean.getMessage());
                        }

                    }
                });
    }

    /**
     * 获取店铺列表
     */
    public void querySelectStory() {
        Map<String, Object> maps = new HashMap<>();
        maps.put("page", 1);
        maps.put("limit", AppConstant.pageSize_big);
        mModel.querySelectStory(maps).compose(RxUtils.applySchedulers(mRootView))
                .subscribe(new ErrorHandleSubscriber<ResultBean<List<MyStoryBean.ResultBean>>>(mErrorHandler) {
                    @Override
                    public void onNext(ResultBean<List<MyStoryBean.ResultBean>> listResultBean) {
                        if (AppUtil.isSuccess(listResultBean)) {
                            mRootView.querySelectStorySuccess(listResultBean.getData());
                        } else {
                            mRootView.showMessage(listResultBean.getMessage());
                        }
                    }
                });
    }

    /**
     * 选择店铺
     *
     * @param activity
     * @param view
     * @param memberCenterUserInfoBean
     * @param resultBeans
     * @param callback
     */
    public void popuwindSelectStore(Activity activity, View view, MemberCenterUserInfoBean memberCenterUserInfoBean, List<MyStoryBean.ResultBean> resultBeans, HousePublishDuanZuPublishPresenter.SelectStoreCallback callback) {

        customPopupWindowSelectStore = new CustomPopupWindow.Builder().contentView(CustomPopupWindow.inflateView(activity, R.layout.housepublishpublish_selectstory)).parentView(view)
                .animationStyle(R.style.mypopwindow_anim_style).customListener(new CustomPopupWindow.CustomPopupWindowListener() {
                    @Override
                    public void initPopupView(View contentView) {

                    }
                }).isHaveBackGround(false).build();
        View view1 = customPopupWindowSelectStore.getContentView();
        popuwindowSelectStoreViewHold = new PopuwindowSelectStoreViewHold(view1);
        popuwindowSelectStoreViewHold.toolbarTitle.setText(ArmsUtils.getString(activity, R.string.housepublishpublish_title_xzgsdp));
        popuwindowSelectStoreViewHold.toolbarTitle.setTextColor(ArmsUtils.getColor(activity, R.color.color_191919));
        popuwindowSelectStoreViewHold.toolbar.setBackgroundColor(ArmsUtils.getColor(activity, R.color.color_EDEDED));
        popuwindowSelectStoreViewHold.toolbarBack.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                customPopupWindowSelectStore.dismiss();
            }
        });
        popuwindowSelectStoreViewHold.housepublishpublishSelectstoryRecyclerView.setLayoutManager(new LinearLayoutManager(activity));
        PublicHouseXZDPItemAdapter adapter = new PublicHouseXZDPItemAdapter(memberCenterUserInfoBean, resultBeans);
        popuwindowSelectStoreViewHold.housepublishpublishSelectstoryRecyclerView.setAdapter(adapter);
        adapter.openLoadAnimation(BaseQuickAdapter.SLIDEIN_RIGHT);
        adapter.setOnItemClickListener(new BaseQuickAdapter.OnItemClickListener() {
            @Override
            public void onItemClick(BaseQuickAdapter adapter, View view, int position) {
                callback.callBack(resultBeans.get(position));
                customPopupWindowSelectStore.dismiss();
            }
        });
        customPopupWindowSelectStore.show();
    }

    public class PopuwindowPublishSuccessViewHold {
        @BindView(R.id.toolbar_backImg)
        ImageView toolbarBackImg;
        @BindView(R.id.toolbar_back)
        RelativeLayout toolbarBack;
        @BindView(R.id.toolbar_title)
        TextView toolbarTitle;
        @BindView(R.id.back_right_icon)
        ImageView backRightIcon;
        @BindView(R.id.back_right_txt)
        TextView backRightTxt;
        @BindView(R.id.toolbar_right)
        RelativeLayout toolbarRight;
        @BindView(R.id.toolbar)
        AutoToolbar toolbar;
        @BindView(R.id.secondhandpublish_msg)
        TextView secondhandpublishMsg;
        @BindView(R.id.secondhandpublish_jxfb)
        TextView secondhandpublishJxfb;
        @BindView(R.id.secondhandpublish_ckwdfb)
        TextView secondhandpublishCkwdfb;

        public PopuwindowPublishSuccessViewHold(View view) {
//            R.layout.secondhandpublish_add_success
            ButterKnife.bind(this, view);
        }
    }

    public class PopuwindowSetPriceViewHold {
        @BindView(R.id.toolbar_backImg)
        ImageView toolbarBackImg;
        @BindView(R.id.toolbar_back)
        RelativeLayout toolbarBack;
        @BindView(R.id.UserSetEditInfoSetTxt_title_txt)
        TextView UserSetEditInfoSetTxtTitleTxt;
        @BindView(R.id.UserSetEditInfoSetTxt_sure_txt)
        TextView UserSetEditInfoSetTxtSureTxt;
        @BindView(R.id.secondHandPublicsh_set_qwmj_txt)
        EditText secondHandPublicshSetQwmjTxt;
        @BindView(R.id.secondHandPublicsh_set_rsj_txt)
        EditText secondHandPublicshSetRsjTxt;
        @BindView(R.id.secondHandPublicsh_conten_dpgs_lay)
        LinearLayout secondHandPublicshContenDpgsLay;

        public PopuwindowSetPriceViewHold(View view) {
//            R.layout.secondhand_publicsh_price_set
            ButterKnife.bind(this, view);
        }
    }

    public class PopuwindowSelectTypeViewHold {
        @BindView(R.id.toolbar_backImg)
        ImageView toolbarBackImg;
        @BindView(R.id.toolbar_back)
        RelativeLayout toolbarBack;
        @BindView(R.id.toolbar_title)
        TextView toolbarTitle;
        @BindView(R.id.back_right_icon)
        ImageView backRightIcon;
        @BindView(R.id.back_right_txt)
        TextView backRightTxt;
        @BindView(R.id.toolbar_right)
        RelativeLayout toolbarRight;
        @BindView(R.id.toolbar)
        AutoToolbar toolbar;
        @BindView(R.id.secondhand_publicsh_selecttype_RecyclerView1)
        RecyclerView secondhandPublicshSelecttypeRecyclerView1;
        @BindView(R.id.secondhand_publicsh_selecttype_RecyclerView2)
        RecyclerView secondhandPublicshSelecttypeRecyclerView2;

        public PopuwindowSelectTypeViewHold(View view) {
//            R.layout.secondhand_publicsh_selecttype
            ButterKnife.bind(this, view);
        }
    }

    public class PopuwindowSelectStoreViewHold {

        @BindView(R.id.toolbar_backImg)
        ImageView toolbarBackImg;
        @BindView(R.id.toolbar_back)
        RelativeLayout toolbarBack;
        @BindView(R.id.toolbar_title)
        TextView toolbarTitle;
        @BindView(R.id.back_right_icon)
        ImageView backRightIcon;
        @BindView(R.id.back_right_txt)
        TextView backRightTxt;
        @BindView(R.id.toolbar_right)
        RelativeLayout toolbarRight;
        @BindView(R.id.toolbar)
        AutoToolbar toolbar;
        @BindView(R.id.housepublishpublish_selectstory_RecyclerView)
        RecyclerView housepublishpublishSelectstoryRecyclerView;

        public PopuwindowSelectStoreViewHold(View view) {
//            R.layout.housepublishpublish_selectstory
            ButterKnife.bind(this, view);
        }
    }


    /**
     * 上传图片
     *
     * @param
     */
    public void updateHeadImg(String path) {
        if (path == null || TextUtils.isEmpty(path)) {
            return;
        }

        AppUtil.upfileToAli(mAppManager.getCurrentActivity(), Api.secondHand, path, new AliYunUploadFileInterface() {
            @Override
            public void AliYunUploadFileCallBackProgress(long currentSize, long totalSize) {

            }

            @Override
            public void AliYunUploadFileCallBackSuccess(PutObjectResult result, String serverPath) {
                mRootView.updateImgSuccess(serverPath);
            }

            @Override
            public void AliYunUploadFileCallBackFailure(ServiceException serviceException) {
                mRootView.updateImgFail();

            }
        });


    }

    /**
     * 请求相机权限
     * type  0 从租房页面直接跳转过来的  1从选择图片页面过来的
     */
    public void requestPrisession() {
        //请求外部存储权限用于适配android6.0的权限管理机制
        PermissionUtil.requestPermission(new PermissionUtil.RequestPermission() {
            @Override
            public void onRequestPermissionSuccess() {
                mRootView.requestPerimissionSuccess();
            }

            @Override
            public void onRequestPermissionFailure(List<String> permissions) {
                mRootView.showMessage("请求相机权限失败");
            }

            @Override
            public void onRequestPermissionFailureWithAskNeverAgain(List<String> permissions) {
                mRootView.showMessage("请同意使用摄像头权限");
            }
        }, mRootView.getPermissions(), mErrorHandler, permission);
    }

    public interface priceSetCall {
        void callBack(String qwjg, String rsj);
    }

    @Override
    public void onDestroy() {
        super.onDestroy();
        this.mErrorHandler = null;
        this.mAppManager = null;
        this.mImageLoader = null;
        this.mApplication = null;
    }
}
